From aa5c183614f56fc833c283b3c18670de79ad13d9 Mon Sep 17 00:00:00 2001 From: Olaf Hering Date: Fri, 24 Oct 2014 16:17:04 +0200 Subject: [PATCH] tools/hotplug: fix conditions in systemd service files for dom0 ConditionVirtualization= checks if systemd runs in some sort of guest. It is not supposed to detect host capabilities. The current implementation happens to work because systemd-detect-virt from v208 returns also 'xen' in a dom0. In v210 and later 'none' is returned and no service files will be started. Adjust the checks to detect a dom0 vs. native boot. Mounting xenfs depends on /proc/xen, but should only be done for pvops because xenfs exists only there. All other service files should not be started in domU. The file /proc/xen/capabilities exists in both dom0 and domU in a pvops kernel, but only in dom0 it contains 'control_d'. The existing ExecStartPre= check will prevent starting in a domU. ConditionVirtualization=!xen is true in a dom0. But this check is broken in systemd v208, so its not used. Signed-off-by: Olaf Hering Cc: Ian Campbell Cc: Ian Jackson Cc: Stefano Stabellini Cc: Wei Liu Acked-by: Wei Liu --- tools/hotplug/Linux/systemd/proc-xen.mount.in | 3 ++- tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in | 4 +++- .../Linux/systemd/xen-qemu-dom0-disk-backend.service.in | 2 +- tools/hotplug/Linux/systemd/xen-watchdog.service.in | 2 +- tools/hotplug/Linux/systemd/xenconsoled.service.in | 2 +- tools/hotplug/Linux/systemd/xendomains.service.in | 2 +- tools/hotplug/Linux/systemd/xenstored.service.in | 2 +- tools/hotplug/Linux/systemd/xenstored.socket.in | 2 +- tools/hotplug/Linux/systemd/xenstored_ro.socket.in | 2 +- 9 files changed, 12 insertions(+), 9 deletions(-) diff --git a/tools/hotplug/Linux/systemd/proc-xen.mount.in b/tools/hotplug/Linux/systemd/proc-xen.mount.in index f0c4f3a556..64ebe7f9b1 100644 --- a/tools/hotplug/Linux/systemd/proc-xen.mount.in +++ b/tools/hotplug/Linux/systemd/proc-xen.mount.in @@ -1,6 +1,7 @@ [Unit] Description=Mount /proc/xen files -ConditionVirtualization=xen +ConditionPathExists=/proc/xen +ConditionPathExists=!/proc/xen/capabilities RefuseManualStop=true [Mount] diff --git a/tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in b/tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in index 44dfce8fc4..6c46be3daa 100644 --- a/tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in +++ b/tools/hotplug/Linux/systemd/var-lib-xenstored.mount.in @@ -1,6 +1,8 @@ [Unit] Description=mount xenstore file system -ConditionVirtualization=xen +Requires=proc-xen.mount +After=proc-xen.mount +ConditionPathExists=/proc/xen/capabilities RefuseManualStop=true [Mount] diff --git a/tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in b/tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in index d3470fcaa2..52101af56a 100644 --- a/tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in +++ b/tools/hotplug/Linux/systemd/xen-qemu-dom0-disk-backend.service.in @@ -4,7 +4,7 @@ Requires=proc-xen.mount var-lib-xenstored.mount xenstored.socket After=xenstored.service xenconsoled.service Before=xendomains.service libvirtd.service libvirt-guests.service RefuseManualStop=true -ConditionVirtualization=xen +ConditionPathExists=/proc/xen/capabilities [Service] Type=simple diff --git a/tools/hotplug/Linux/systemd/xen-watchdog.service.in b/tools/hotplug/Linux/systemd/xen-watchdog.service.in index ee77bf97ae..1eecd2a616 100644 --- a/tools/hotplug/Linux/systemd/xen-watchdog.service.in +++ b/tools/hotplug/Linux/systemd/xen-watchdog.service.in @@ -2,7 +2,7 @@ Description=Xen-watchdog - run xen watchdog daemon Requires=proc-xen.mount After=proc-xen.mount xendomains.service -ConditionVirtualization=xen +ConditionPathExists=/proc/xen/capabilities [Service] Type=forking diff --git a/tools/hotplug/Linux/systemd/xenconsoled.service.in b/tools/hotplug/Linux/systemd/xenconsoled.service.in index 7ca0264690..6ab0fc1a2f 100644 --- a/tools/hotplug/Linux/systemd/xenconsoled.service.in +++ b/tools/hotplug/Linux/systemd/xenconsoled.service.in @@ -2,7 +2,7 @@ Description=Xenconsoled - handles logging from guest consoles and hypervisor Requires=xenstored.socket After=xenstored.service -ConditionVirtualization=xen +ConditionPathExists=/proc/xen/capabilities [Service] Type=simple diff --git a/tools/hotplug/Linux/systemd/xendomains.service.in b/tools/hotplug/Linux/systemd/xendomains.service.in index f88c336660..2684df0605 100644 --- a/tools/hotplug/Linux/systemd/xendomains.service.in +++ b/tools/hotplug/Linux/systemd/xendomains.service.in @@ -2,7 +2,7 @@ Description=Xendomains - start and stop guests on boot and shutdown Requires=xenstored.socket After=xenstored.service xenconsoled.service -ConditionVirtualization=xen +ConditionPathExists=/proc/xen/capabilities [Service] Type=oneshot diff --git a/tools/hotplug/Linux/systemd/xenstored.service.in b/tools/hotplug/Linux/systemd/xenstored.service.in index 013e69e792..0f0d77dab5 100644 --- a/tools/hotplug/Linux/systemd/xenstored.service.in +++ b/tools/hotplug/Linux/systemd/xenstored.service.in @@ -4,7 +4,7 @@ Requires=xenstored_ro.socket xenstored.socket proc-xen.mount var-lib-xenstored.m After=proc-xen.mount var-lib-xenstored.mount Before=libvirtd.service libvirt-guests.service RefuseManualStop=true -ConditionVirtualization=xen +ConditionPathExists=/proc/xen/capabilities [Service] Type=notify diff --git a/tools/hotplug/Linux/systemd/xenstored.socket.in b/tools/hotplug/Linux/systemd/xenstored.socket.in index 461e4f4786..9b28e7481a 100644 --- a/tools/hotplug/Linux/systemd/xenstored.socket.in +++ b/tools/hotplug/Linux/systemd/xenstored.socket.in @@ -1,6 +1,6 @@ [Unit] Description=xenstore socket -ConditionVirtualization=xen +ConditionPathExists=/proc/xen/capabilities [Socket] ListenStream=/var/run/xenstored/socket diff --git a/tools/hotplug/Linux/systemd/xenstored_ro.socket.in b/tools/hotplug/Linux/systemd/xenstored_ro.socket.in index 6ab5c28f29..80402b39ef 100644 --- a/tools/hotplug/Linux/systemd/xenstored_ro.socket.in +++ b/tools/hotplug/Linux/systemd/xenstored_ro.socket.in @@ -1,6 +1,6 @@ [Unit] Description=xenstore ro socket -ConditionVirtualization=xen +ConditionPathExists=/proc/xen/capabilities [Socket] ListenStream=/var/run/xenstored/socket_ro -- 2.30.2